﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using System.Data.Linq.Mapping;
using Viewer.BusinessObject.BusinessEntities;


namespace Viewer.History.BusinessObject.BusinessEntities
{
    public class HistoryGeneral
    {
        private int _LogID;
        private int _UserID;
        private string _UserName;
        private int _FunctionID;
	    private int _ActionTypeID;
        private string _ActionTypeName;
	    private DateTime _UpdateDateTime;
	    private string _TableName;
        private int _TableLogID;
        DataClassesDataContext dataContext = new DataClassesDataContext();

        public HistoryGeneral(){ }

        [Column(Storage = "_LogID", DbType = "Int NOT NULL")]
        public int LogID
        {
            get
            {
                return this._LogID;
            }
            set
            {
                if ((this._LogID != value))
                {
                    this._LogID = value;
                }
            }
        }

        [Column(Storage = "_UserID", DbType = "Int NOT NULL")]
        public int UserID
        {
            get
            {
                return this._UserID;
            }
            set
            {
                if ((this._UserID != value))
                {
                    this._UserID = value;
                }
            }
        }

        [Column(Storage = "_UserName", DbType = "VARCHAR(50)")]
        public string UserName
        {
            get
            {
                return this._UserName;
            }
            set
            {
                QUNguoiDung nguoiDung = new QUNguoiDung();
                nguoiDung = nguoiDung.LoadDataById(_UserID);
                if (nguoiDung != null) _UserName = nguoiDung.TenDangNhap;
                else _UserName = "";
            }
        }

        [Column(Storage = "_FunctionID", DbType = "Int NOT NULL")]
        public int FunctionID
        {
            get
            {
                return this._FunctionID;
            }
            set
            {
                if ((this._FunctionID != value))
                {
                    this._FunctionID = value;
                }
            }
        }

        [Column(Storage = "_ActionTypeID", DbType = "Int NOT NULL")]
        public int ActionTypeID
        {
            get
            {
                return this._ActionTypeID;
            }
            set
            {
                if ((this._ActionTypeID != value))
                {
                    this._ActionTypeID = value;
                }
            }
        }

        [Column(Storage = "_ActionTypeName", DbType = "NVARCHAR(200)")]
        public string ActionTypeName
        {
            get
            {
                return this._ActionTypeName;
            }
            set
            {
                switch (_ActionTypeID)
                {
                    case 1:
                        _ActionTypeName = Viewer.Base.Config.ViewerConstant.History_ActionTypeNameAdd;
                        break;
                    case 2:
                        _ActionTypeName = Viewer.Base.Config.ViewerConstant.History_ActionTypeNameEdit;
                        break;
                    case 3:
                        _ActionTypeName = Viewer.Base.Config.ViewerConstant.History_ActionTypeNameDelete;
                        break;
                    default:
                        _ActionTypeName = "Không xác định";
                        break;
                }
            }
        }

        [Column(Storage = "_UpdateDateTime", DbType = "DateTime NOT NULL")]
        public DateTime UpdateDateTime
        {
            get
            {
                return this._UpdateDateTime;
            }
            set
            {
                if ((this._UpdateDateTime != value))
                {
                    this._UpdateDateTime = value;
                }
            }
        }

        [Column(Storage = "_TableName", DbType = "VARCHAR(50) NOT NULL")]
        public string TableName
        {
            get
            {
                return this._TableName;
            }
            set
            {
                if ((this._TableName != value))
                {
                    this._TableName = value;
                }
            }
        }

        [Column(Storage = "_TableLogID", DbType = "Int NOT NULL")]
        public int TableLogID
        {
            get
            {
                return this._TableLogID;
            }
            set
            {
                if ((this._TableLogID != value))
                {
                    this._TableLogID = value;
                }
            }
        }
    }
}